<?php
header('Content-Type:text/html;Charset=UTF-8');

session_start();

if(isset($_SESSION['userId'])){

}else {
	die('<h3>登录信息不完整</h3><a href="/index.php">返回重新登录</a>');
};

@$id = $_SESSION['userId'];

@$pageNo = $_REQUEST['pageNo'];

if (empty($pageNo)||!is_numeric($pageNo)||$pageNo<1){
	$pageNo = 1;
}

$pageSizet = 6;

$offset = ($pageNo-1)*$pageSizet;


require 'lib/db.php';


@$users = dbSelect("select u.id as uid,login,password,roleId,r.name as rname,w.id as wid,w.name as wname,age,sex,contact,address,img from users as u join role as r on u.roleId=r.id join worker as w on u.id=w.id",array('id'=>$id));



@$itemCount = dbSelect('select count(1) as x from client');

$pageCount = ceil($itemCount['x']/$pageSizet);


@$list = dbSelectAll("select id,name,age,sex,contact,address,img from client order by id asc limit $offset,$pageSizet");


?>

<!DOCTYPE html>
<html>
   <head>
      <title>CRM客户关系管理系统</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="bootstrap/css/bootstrap-submenu.css" rel="stylesheet">
      <link href="bootstrap/css/superfish.css" rel="stylesheet">
      <link href="bootstrap/css/superfish-vertical.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <script src="bootstrap/js/bootstrap-submenu.js"></script>
      <script src="bootstrap/js/superfish.js"></script>
      <!--[if lt IE 9]>
         <script src="js/html5shiv.js"></script>
         <script src="js/respond.min.js"></script>
      <![endif]-->
   </head>
  <script src="lib/menu.js"></script>
   <script src="lib/red.js"></script>
    <script src="lib/dialog.js"></script>
<script>
$(function(){
		$('.menus').menu();

		$.ajaxSetup({
			dataType:'JSON',
			error:function(){
				alert('服务器交互出错！');
				}
			});
		$('#logoutBtn').click(function(){
			confirmDialog('提示','确定退出？');
			$('#confirm').click(function(){
				});
			});
			
	});
</script>
<style>
	#confirm{color:red}
	.header{background:#681709}
	.modaltitle{color:white;font-size:20px}
	.navbar{background:#681709;}
	.marginal{height:10px;background:red}
	.title{font-size:30px;text-align:cneter;background:}
	#span{color:#e8e8e8;}
	#c{color:#ff8d1c;}
	#R{color:#ffff1e;}
	#M{color:#00ff00;}
	#logoutBtn{font-size:18px;color:red}
	.font{margin:0px;height:59px;text-align:center;width:270px;background:#681709}
	#user{border:solid 1px;width:240px;height:32px;text-align:left;background:black;color:white}
	#users{width:80px;float:left;border:solid 1px;background:black;color:white}
	#marginal{height:490px;width:15px;background:#681709;border-radius:10px;float:left}
	.menus a{display:block;width:200px;font-size:25px;}
    .menu{display:none;text-align:center}
    #a{font-size:16px;color:white;background:#681709}
    .titles{border:solid 3px;width:210px;border-radius:15px}
    .panel{color:#681709;border:solid 3px}
#FirstBtn{font-size:18px;color:red}
.col{color:#681709;border:solid 3px;margin:10px}
.tr{background:#681709;color:white}
.BUT{text-align:center}
#A{background:#681709;color:white;font-size:17px;}
.thumbnail{border:solid 1px;}
#Panel{background:#681709;color:white}
#d{height:35px;}
#font{color:black}
#mes{color:red}
.basic{width:80px}
 </style>
  <body>
  	<nav class="navbar navbar-default">
 			<div class="row navbar-form">
 				<div class="col-xs-3 title">
 					<span id="c">C</span><span id="R">R</span><span id="M">M</span><span id="span">客户关系管理系统</span>
 				</div>
 				<div class="col-xs-6 text-right fonts">
 					
 				</div>
 				<div class="col-xs-3 text-right font">
 					<div id="user">
 					<img src="img/<?php echo $users['img']; ?>" style="width: 20px;height: 20px">
 					在线用户：<?php echo $users['wname']; ?>--<<?php echo $users['rname']; ?>>
 					</div>
 					<div id="users">
 					<a href="First.php" id="FirstBtn">首　页</a>
 					</div>
 					<div id="users">
 					<a href="#" id="logoutBtn" data-toggle="modal">退出系统</a>
 					</div>
 					<div id="users">
 					<a href="#" id="FirstBtn" data-toggle="modal">帮　助</a>
 					</div>
 				</div>
 				
 			</div>
 		</nav>
 	
 	<div class="container">
	 	<div class="row">
		 		<div class="col-xs-12">
	 			<div  id="marginal"></div>
	 			<div class="col-xs-3 titles">
	 			<ul class="sf-menu sf-vertical">
						<li class="current">
							<a href="#" id="a">用户登陆管理</a>
							<ul>
								<li><a href="Alteruse.php" id="a">个人资料信息</a></li>
								<li><a href="Alterinfo.php" id="a">个人信息修改</a></li>
							</ul>
						</li>
						<li><a href="#" id="a">我的客户管理</a>
							<ul>
							<li><a href="success.php"id="a">成功客户列表</a></li>
				   			<li><a href="seekIn.php"id="a">挑入记录列表</a></li>
				   			<li><a href="seekOut.php"id="a">挑出记录列表</a></li>
				   			<li><a href="myClient.php"id="a">我的客户列表</a></li>
				   			<li><a href="publicClient.php"id="a">公共客户列表</a></li>
							</ul>
						</li>
						<li><a href="#" id="a">业务产品管理</a>
							<ul>
								<li><a href="companyProduct.php"id="a">公司产品</a></li>
				   				<li><a href="myTrade.php"id="a">我的交易</a></li>
				   			</ul>
				   		</li>
						<li><a href="#" id="a">全部客户管理</a>
							<ul>
								<li><a href="allClient.php"id="a">全部客户列表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">全体职员管理</a>
							<ul>
								<li><a href="allphpWorker.php"id="a">全体职员列表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">销售客户统计</a>
							<ul>
								<li><a href="#"id="a">全体销售代表成绩表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">销售部门管理</a>
							<ul>
								<li><a href="sell.php"id="a">销售部列表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">系统用户管理</a>
							<ul>
								<li><a href="systemUse.php"id="a">系统用户列表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">角色权限管理</a>
							<ul>
								<li><a href="systemUseRole.php"id="a">系统用户角色列表</a></li>
				   			</ul>
						</li>
						<li><a href="#" id="a">客户跟进管理</a>
							<ul>
								<li><a href="#"id="a">待跟进客户列表</a></li>
				   				<li><a href="myTabb.php"id="a">我的客户跟进列表</a></li>
				   			</ul>
						</li>
					</ul>
	 			</div>
	 			<div class="col-xs-8 main">
				 	<div class="panel panel-default">
			 			<div class="panel-heading">
			 				<div id="d">
			 					<div class="col-xs-4">
					 				<h5 class="panel-title title">全部客户列表</h5>
			 					</div>
			 					<div class="col-xs-6"></div>
			 					<div class="col-xs-2">
					 				<a href="AddClient.php"  id="font">添加客户</a>
			 					</div>
			 				</div>
			 			</div>
			 			<div class="panel-body">
			 			<?php foreach ($list as $eitm){?>
			 				<div class="col-xs-4">
				 				<div class="thumbnail">
				 					<img src="img/<?php echo $eitm['img'];?>" style="width: 130px;height: 140px"/>
				 					<div class="id">
					 					姓名：<?php echo $eitm['name']; ?>
				 					</div>
				 					<div class="id">
				 						性别：<?php echo $eitm['sex']; ?>
				 					</div>
				 					<div class="id">
				 						年龄：<?php echo $eitm['age']; ?>
				 					</div>
				 					<div class="id">
				 						<a href="#" data-toggle="modal" data-target="#1">联系信息</a>　
				 						<a href="UpdateClient.php?id=<?php echo $eitm['id']; ?>" id="mes">修改</a>
				 						<a href="DeleteClient.php?id=<?php echo $eitm['id']; ?>">删除</a>
				 					</div>
				 				</div>
			 					
			 				</div>
			 				<?php }?>
			 				<div class="col-xs-12 BUT">
					 			<a href="?pageNo=1" id="A">首　页</a>
						 		<?php if($pageNo<=1){?>
									上一页
								<?php }else{?>
					 			<a href="?pageNo=<?php echo $pageNo-1; ?>" id="A">上一页</a>
					 			<?php }?>
							
								<?php if($pageNo>=$pageCount){?>
									下一页
								<?php }else{?>
					 			<a href="?pageNo=<?php echo $pageNo+1; ?>" id="A">下一页</a>
					 			<?php }?>
					 			<a href="?pageNo=<?php echo $pageCount; ?>" id="A">末　页</a>
					 			当前第<?php echo $pageNo ?>页
					 			总共<input value="<?php echo $pageCount ?>" size="2"/>页
					 			<a href="First.php" id="A">上一级</a>
					 		</div>
			 			</div>
			 		</div>
	 			</div>
	 		</div>
	 	</div>
	  	
	  	<div class="modal" id="1">
			<div class="col-sm-3 col-xs-offset-5">
		        <div class="panel">
			            <div class="panel-heading" id="Panel">
			               <h5>客户《<?php echo $eitm['name']; ?>》－基本信息</h5>
			            </div>
		                    <div class="panel-body">
		                    <form id="stockFrom" class="form-horizontal" enctype="multipart/form-data" action="Addstock.php" method="post">
		                    <table class="table table-bordered table-hover">
									<tbody>
										<tr>
											<td class="basic">联系方式</td>
											<td><?php echo $eitm['contact']; ?></td>
										</tr>
										<tr>
											<td class="basic">常住住址</td>
											<td><?php echo $eitm['address']; ?></td>
										</tr>
									</tbody>
								</table>
		                    <div class="row">
		                        <div class="col-xs-3 col-xs-offset-9">
		                          	<a type="button" class="btn btn-default" data-dismiss="modal">关闭</a>
		                        </div>
		                    </div>
		                    </form>
		            </div>
		        </div>
			</div>
		</div>
 		
 	</div>
 </body>
   <script>
   	$('.dropdown-submenu > a').submenupicker();
   	$('.sf-menu').superfish();
   </script>
</html>